import os
import shutil

class_name = ['bed', 'blanket', 'bottle',  'cabinet', 'cat', 
                 'chair', 'chair_base', 'charger', 'cupboard', 'dining_table',
                'dirt', 'dog', 'door_anno', 'door_sill', 'invalid',
                'person', 'pet_feces', 'refrigerator', 'shoe', 'shoe_cabinet',
                 'slipper', 'socks', 'sofa', 'sweeping_machine', 'tea_table',
                  'tile_floor', 'toilet', 'TV_stand', 'unknown', 'washing_machine',
                   'wastebin', 'wire', 'wood_floor',
                 ]
    
def check_path(path):
    if not os.path.exists(path):
        os.makedirs(path)

def get_im(txt_path, save_path):
    shutil.copyfile(txt_path.split(',')[0], save_path)
      
if __name__ == "__main__":

    txt_path = '/home/ailab2/Documents/train_data/classification/33class_all_20200916_ori_aux_resize_96/RBG100w_classifer_out_20200917/10/all_right_im.txt'
    resize_im_path = '/home/ailab2/Documents/train_data/classification/33class_all_20200914_ori/RGB100w_floor/resize_96/10'
    save_path = '/home/ailab2/Documents/train_data/classification/33class_all_20200916_ori_aux_resize_96/RBG100w_classifer_out_20200917/3model_10/'
    with open(txt_path) as f:
        for i in f.readlines():
            s = i.split(',')
            temp_save_path = save_path + class_name[int(float(s[1]))]
            check_path(temp_save_path)
            get_im(i, os.path.join(temp_save_path, os.path.basename(s[0])))

    
            